<?php

/**
 * Image class
 */
class str_SmugMugImage extends str_SmugMugEntity {

    private $_smugMugAlbum;

    public function __construct(Array $data, phpSmug $phpSmug, str_SmugMugAlbum $smugMugAlbum) {
        $this->_smugMugAlbum = $smugMugAlbum;
        parent::__construct($data, $phpSmug);
    }
    
    public function getTinyUrl() {
        $data = $this->getData();
        return $data['TinyURL'];
    }
    
    public function getCaption() {
        if ($this->isNullObject()) {
            return '';
        }
        
        $data = $this->getData();
        return $data['Caption'];
    }
    
    public function getAlbum() {
        return $this->_smugMugAlbum;
    }
    
    public function getLinkTitle() {
        $title = $this->getAlbum()->getTitle();
        if ($this->getCaption() != '') {
            $title .= ' -> ' . $this->getCaption();   
        }
        return $title;
    }
    
    /**
     * Returns URL to the image's place in album
     * @return string
     */
    public function getInAlbumUrl() {
        return $this->getAlbum()->getUrl() . '#' . $this->getId() . '_' . $this->getKey();
    }
    
}